package com.trade.wzj.service.yang.impl;

import java.util.List;

import com.trade.wzj.dao.yang.Supplier_quotaDao;
import com.trade.wzj.model.xiang.ProductInfoQuota;
import com.trade.wzj.model.xiang.SupplierInfo;
import com.trade.wzj.model.xiang.SupplierQuota;
import com.trade.wzj.service.yang.Supplier_quotaService;

public class Supplier_quotaImpl_Yang implements Supplier_quotaService {

	private Supplier_quotaDao supplier_quotaDao;

	public Supplier_quotaDao getSupplier_quotaDao() {
		return supplier_quotaDao;
	}

	public void setSupplier_quotaDao(Supplier_quotaDao supplier_quotaDao) {
		this.supplier_quotaDao = supplier_quotaDao;
	}

	@Override
	public List<SupplierQuota> findSupplierQuota(String supplierName) throws Exception {
		List<SupplierQuota> list = null;
		try {
			list = supplier_quotaDao.findSupplierQuota(supplierName);
			for (SupplierQuota supplierQuota : list) {
				System.out.println(supplierQuota);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception();
		}
		return list;

	}

	@Override
	public List<SupplierQuota> findSupplierQuotaById(Integer id) throws Exception {
		List<SupplierQuota> list = null;
		if (null == id) {
			throw new Exception("未选中任何供应商报价单！");
		} else {
			list = supplier_quotaDao.findSupplierQuotaById(id);
			for (SupplierQuota supplierQuota : list) {
				System.out.println(supplierQuota);
			}
		}
		return list;

	}

	@Override
	public List<SupplierQuota> findSupplierQuotaByProductName(String productName) throws Exception {
		List<SupplierQuota> list = null;
		try {
			list = supplier_quotaDao.findSupplierQuotaByProductName(productName);
			for (SupplierQuota supplierQuota : list) {
				System.out.println(supplierQuota);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception();
		}
		return list;

	}

	@Override
	public List<SupplierQuota> getListProduct(int[] list) throws Exception {
		List<SupplierQuota> arry = supplier_quotaDao.getListProduct(list);
		return arry;
	}

	//查询所有供应商报价信息，且可模糊查询供应商报价根据报价编号
	@Override
	public List<SupplierQuota> getAllSupplierQuotaInfos(String supplierQuotaID) throws Exception {
		List<SupplierQuota> list=null;
		try {
			list=supplier_quotaDao.getAllSupplierQuotaInfos(supplierQuotaID);
		} catch (Exception e) {
			throw new Exception();
		}
		return list;
	}

	//通过供应商id查询供应商报价产品
	@Override
	public List<ProductInfoQuota> checkAllProductBySupplierInfo(Integer supplierInfoID) throws Exception {
		List<ProductInfoQuota> list=null;
		try {
			list=supplier_quotaDao.checkAllProductBySupplierInfo(supplierInfoID);
			System.out.println(list.size());
			
			for (ProductInfoQuota productInfoQuota : list) {
				System.out.println(productInfoQuota);
			}
		} catch (Exception e) {
			throw new Exception();
		}
		return list;
	}

	//添加供应商报价表信息
	@Override
	public void addSupplierPrice(SupplierQuota supplierQuota) throws Exception {
		try {
			supplier_quotaDao.addSupplierPrice(supplierQuota);
		} catch (Exception e) {
			throw new Exception();
		}
		
	}

	//查询所有供应商基本信息及按照供应商基本id查询
	@Override
	public List<SupplierInfo> checkAllSupplierInfos(Integer supplierInfoID)throws Exception {
		List<SupplierInfo> list=null;
		try {
			list=supplier_quotaDao.checkAllSupplierInfos(supplierInfoID);
		} catch (Exception e) {
			throw new Exception();
		}
		return list;
	}

	//通过供应商编号查询报价编号
	@Override
	public Integer getSupplierId(Integer supplierInfoID) throws Exception {
		Integer result=null;
		try {
			result=supplier_quotaDao.getSupplierId(supplierInfoID);
		} catch (Exception e) {
			throw new Exception();
		}
		return result;
	}

	//添加供应商产品表信息
	@Override
	public void addProducts(ProductInfoQuota productInfoQuota) throws Exception {
		try {
			supplier_quotaDao.addProducts(productInfoQuota);
		} catch (Exception e) {
			throw new Exception();
		}
	}

	@Override
	public List<SupplierInfo> getSupplierInfoB(Integer id) throws Exception {
		List<SupplierInfo> list = null;
		try {
			list=supplier_quotaDao.getSupplierInfoB(id);
		} catch (Exception e) {
			throw new Exception();
		}
		return list;
	}

}
